package org.ekingstar.webService;

import java.util.List;

import org.ekingstar.qd.domain.QdCompareCond;
import org.ekingstar.qd.domain.QdCompareType;
import org.ekingstar.qd.domain.QdHisCond;
import org.ekingstar.qd.domain.QdSysParam;
import org.ekingstar.qd.domain.QdWhereClause;
import org.ekingstar.qd.service.CConditionService;

import com.ekingstar.framework.util.ServiceLocator;

/**
 * 查询条件、过滤条件、历史条件业务处理webService
 * @author 
 */
public class CConditionWebService {
	/**
	 * @descripte 根据查询类别ID号,获取查询类别信息 
	 * @param strCompareTypeId 查询类别ID号集	
	 * @return List
	 */
	public List<QdCompareType> getCompareTypeList(String[] strCompareTypeId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getCompareTypeList(strCompareTypeId);
	}
	
	/**
	 * @descripte 获取所有查询类别信息 
	 * @param 无	
	 * @return List
	 */
	public List<QdCompareType> getCompareTypeList(){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getCompareTypeList();
	}
	
	/**
	 * @descripte 根据主题id号，获取该主题的所有查询条件信息 
	 * @param strDomainId 主题ID号	
	 * @return List
	 */
	public List<QdCompareCond> getCompareCondList(String strDomainId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getCompareCondList(strDomainId);
	}
	
	
	/**
	 * @descripte 根据查询条件ID号获取查询条件
	 * @param strConditionId  查询条件ID号
	 * @return QdCompareCond
	 */
	public QdCompareCond getCompareCond(String strConditionId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getCompareCond(strConditionId);
	}
	
	
	/**
	 * @descripte 根据字段ID号获取查询SQL
	 * @param strFieldId      字段ID号
	 * @param nConditionType  条件类型
	 * @return String
	 */
	public String getCompareCondSqlByFiedlId(String strFieldId,int nConditionType){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getCompareCondSqlByFiedlId(strFieldId, nConditionType);
	}
	

	/**
	 * @descripte 检查SQL语句是否符合要求 
	 * @param  sql 待检查的SQL语句
	 * @return int 正确返回1,否则为 -1
	 */
	public int checkSql(String sql){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.checkSql(sql);
	}
	
	
	/**
	 * @descripte 新增查询字段条件，成功为1,失败为-1
	 * @param strDomainId            主题ID号
	 * @param strName                字段名称
	 * @param strDescript            关系描述
	 * @param nType                  条件类型
	 * @param strSql                 字段SQL语句
	 * @param nAutoSingleQuotation   是否自动添加引号，0为否，1为是
	 * @param strFieldId             字段ID号
	 * @param colStr                 查询条件表达式            
	 * @return int
	 */
	public int addCompareCond(String strDomainId,String strName,String strDescript,int nType,String strSql,int nAutoSingleQuotation,String strFieldId,String colStr){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.addCompareCond(strDomainId, strName, strDescript, nType, strSql, nAutoSingleQuotation, strFieldId, colStr);
	}
	
	
	/**
	 * @descripte 修改查询字段条件，成功为1,失败为-1
	 * @param strConditionId         查询条件ID号
	 * @param strName                字段名称
	 * @param strDescript            关系描述
	 * @param nType                  条件类型
	 * @param strSql                 字段SQL语句
	 * @param nAutoSingleQuotation   是否自动添加引号，0为否，1为是
	 * @param strFieldId             字段ID号
	 * @param colStr                 查询条件表达式
	 * @return int
	 */
	public int updateCompareCond(String strConditionId,String strName,String strDescript,int nType,String strSql,int nAutoSingleQuotation,String strFieldId,String colStr){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.updateCompareCond(strConditionId, strName, strDescript, nType, strSql, nAutoSingleQuotation, strFieldId, colStr);
	}
	
	
	/**
	 * @descripte 删除查询条件，成功返回1，否则返回-1
	 * @param strConditionId        查询条件ID号集
	 * @return int
	 */
	public int delCompareCond(String[] strConditionId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.delCompareCond(strConditionId);
	}
	
		
	/**
	 * @descripte 根据主题id号，获取该主题的所有获取过滤条件
	 * @param strDomainId 主题ID号	
	 * @return List
	 */
	public List<QdWhereClause> getWhereCauseList(String strDomainId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getWhereCauseList(strDomainId);
	}
	
	
	/**
	 * @descripte 根据过滤条件ID号获取获取过滤条件
	 * @param strWhereCauseId  过滤条件ID号
	 * @return QdWhereClause
	 */
	public QdWhereClause getWhereCause(String strWhereCauseId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getWhereCause(strWhereCauseId);
	}
	
	
	/**
	 * @descripte 新增过滤条件，成功返回1，否则返回-1
	 * @param strDomainId            主题ID号
	 * @param strName                条件名称
	 * @param strCondStr             条件值
	 * @return int
	 */
	public int addWhereClause(String strDomainId,String strName,String strCondStr){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.addWhereClause(strDomainId, strName, strCondStr);
	}
	
	
	/**
	 * @descripte 修改过滤条件，成功返回1，否则返回-1
	 * @param strWhereCauseId        过滤条件ID号
	 * @param strName                条件名称
	 * @param strCondStr             条件值
	 * @return int
	 */
	public int updateWhereClause(String strWhereCauseId,String strName,String strCondStr){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.updateWhereClause(strWhereCauseId, strName, strCondStr);
	}
	
	
	/**
	 * @descripte 删除过滤条件，成功返回1，否则返回-1
	 * @param strWhereCauseId        过滤条件ID号
	 * @return int
	 */
	public int delWhereClause(String[] strWhereCauseId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.delWhereClause(strWhereCauseId);
	}
		
	
	/**
	 * @descripte 根据主题id号，获取该主题的所有历史条件
	 * @param strDomainId 主题ID号	
	 * @return List
	 */
	public List<QdHisCond> getHisConditionList(String strDomainId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getHisConditionList(strDomainId);
	}
	

	/**
	 * @descripte 根据主题id号和用户登录号，获取历史条件信息
	 * @param strDomainId 主题ID号	
	 * @return List
	 */
	public List<QdHisCond> getHisConditionByUserList(String strDomainId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getHisConditionByUserList(strDomainId);
	}
	
	
	/**
	 * @descripte 根据历史条件ID号获取获取历史条件
	 * @param strHisConditionId  历史条件ID号
	 * @return QdHisCond
	 */
	public QdHisCond getHisCondition(String strHisConditionId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getHisCondition(strHisConditionId);
	}
	
	
	/**
	 * @descripte 新增历史查询条件，成功返回1，否则返回-1
	 * @param strDomainId            主题ID号
	 * @param strName                条件名称
	 * @param strDescript            条件描述
	 * @param strCondStr             条件值
	 * @param strCondStrCn           条件中文描述
	 * @param fieldstr               查询列ID
	 * @param orderstr               排序列ID
	 * @param orderstrtype           排序方式
	 * @param contype                条件类型
	 * @return int
	 */
	public int addHisCondition(String strDomainId,String strName,String strDescript,String strCondStr,String strCondStrCn,String fieldstr,String orderstr,String orderstrtype,String contype){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.addHisCondition( strDomainId, strName, strDescript, strCondStr, strCondStrCn, fieldstr, orderstr, orderstrtype, contype);
	}
	
	
	/**
	 * @descripte 修改历史查询条件，成功返回1，否则返回-1
	 * @param strHisConditionId      历史条件ID号
	 * @param strName                条件名称
	 * @param strDescript            条件描述
	 * @param strCondStr             条件值
	 * @param strCondStrCn           条件中文描述
	 * @return int
	 */
	public int updateHisCondition(String strHisConditionId,String strName,String strDescript,String strCondStr,String strCondStrCn){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.updateHisCondition(strHisConditionId, strName, strDescript, strCondStr, strCondStrCn);
	}
	
	
	/**
	 * @descripte 删除历史查询条件，成功返回1，否则返回-1
	 * @param strHisConditionId        历史条件ID号集
	 * @return int
	 */ 
	public int delHisCondition(String[] strHisConditionId){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.delHisCondition(strHisConditionId);
	}
	
	/**
	 * @descripte 获取系统变量	
	 * @return List
	 */
	public List<QdSysParam> getQdSysParamList(){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getQdSysParamList();
	}
	
	/**
	 * @descripte 根据系统变量ID获取系统变量	
	 * @param  id 系统变量ID
	 * @return QdSysParam
	 */
	public QdSysParam getQdSysParam(String id){
		CConditionService cConditionService = (CConditionService)ServiceLocator.getInstance().getBean("conditionService");
		return cConditionService.getQdSysParam(id);
	}
}
